package com.example.backblog.repository.blog;

import com.example.backblog.entity.blog.Blog;
import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
@Primary
public interface BlogRepository extends JpaRepository<Blog, Long> {
    Page<Blog> findAllByTitleLike(String title, Pageable pageable);
    Page<Blog> findAllByIdIn(List<Long> ids,Pageable pageable);
    Integer countAllByCategoryIdEquals(Long category);

    Page<Blog> findAllByOrderByViewsDesc(Pageable pageable);
    Page<Blog> findAllByCategoryIdEquals(Long categoryId, Pageable pageable);

//    Page<Blog> findAllByIdIn(List<Long> ids,Pageable pageable);
    Page<Blog> findAllByIdInAndCategoryIdEquals(List<Long> ids,Long categoryId,Pageable pageable);

    Blog findFirstByTopEquals(Boolean top);

}